/*  1:   */ package com.rinsi.app.zhcx.qycx;
/*  2:   */ 
/*  3:   */ import com.rinsi.core.contoller.CoreSimpleController;
/*  4:   */ import com.rinsi.core.service.CoreSimpleService;
/*  5:   */ import java.io.BufferedInputStream;
/*  6:   */ import java.io.BufferedOutputStream;
/*  7:   */ import java.io.File;
/*  8:   */ import java.io.FileInputStream;
/*  9:   */ import java.util.HashMap;
/* 10:   */ import java.util.List;
/* 11:   */ import java.util.Map;
/* 12:   */ import javax.servlet.ServletContext;
/* 13:   */ import javax.servlet.http.HttpServletRequest;
/* 14:   */ import javax.servlet.http.HttpServletResponse;
/* 15:   */ import javax.servlet.http.HttpSession;
/* 16:   */ import net.sf.jxls.transformer.XLSTransformer;
/* 17:   */ import org.springframework.beans.factory.annotation.Autowired;
/* 18:   */ import org.springframework.stereotype.Controller;
/* 19:   */ import org.springframework.ui.ModelMap;
/* 20:   */ import org.springframework.web.bind.annotation.RequestMapping;
/* 21:   */ 
/* 22:   */ @Controller
/* 23:   */ @RequestMapping({"/zhcx/qycx"})
/* 24:   */ public class ZhcxQycxController
/* 25:   */   extends CoreSimpleController
/* 26:   */ {
/* 27:   */   @Autowired
/* 28:   */   private ZhcxQycxService zhcxService;
/* 29:   */   
/* 30:   */   public CoreSimpleService servce()
/* 31:   */   {
/* 32:33 */     return this.zhcxService;
/* 33:   */   }
/* 34:   */   
/* 35:   */   @RequestMapping({"/downloadEx"})
/* 36:   */   public void downloadEx(ModelMap model, HttpServletRequest request, HttpServletResponse response)
/* 37:   */   {
/* 38:39 */     String tplPath = request.getSession().getServletContext().getRealPath("") + "/tpl/tpQyxx.xls";
/* 39:   */     
/* 40:41 */     String filepath = request.getSession().getServletContext().getRealPath("") + "/temp/" + request.getParameter("UID");
/* 41:   */     
/* 42:43 */     new File(filepath).mkdirs();
/* 43:   */     
/* 44:45 */     String excelFileName = "企业基本情况信息表.xls";
/* 45:   */     
/* 46:47 */     Map<String, Object> beans = new HashMap();
/* 47:   */     
/* 48:49 */     List<Map<String, Object>> list = this.zhcxService.downloadEx(model);
/* 49:   */     
/* 50:51 */     beans.put("datas", list);
/* 51:   */     
/* 52:53 */     XLSTransformer transformer = new XLSTransformer();
/* 53:   */     
/* 54:55 */     BufferedOutputStream bos = null;
/* 55:   */     try
/* 56:   */     {
/* 57:59 */       transformer.transformXLS(tplPath, beans, filepath + "/" + excelFileName);
/* 58:   */       
/* 59:61 */       BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filepath + "/" + excelFileName));
/* 60:   */       
/* 61:63 */       byte[] buff = new byte[2048];
/* 62:   */       
/* 63:65 */       response.setContentType("text/html;charset=UTF-8");
/* 64:   */       
/* 65:67 */       request.setCharacterEncoding("UTF-8");
/* 66:   */       
/* 67:69 */       response.setContentType("application/x-msdownload;");
/* 68:   */       
/* 69:71 */       response.setHeader("Content-disposition", "attachment; filename=" + new String(excelFileName.getBytes("gb2312"), "iso-8859-1"));
/* 70:   */       
/* 71:73 */       bos = new BufferedOutputStream(response.getOutputStream());
/* 72:   */       int bytesRead;
/* 73:77 */       while (-1 != (bytesRead = bis.read(buff, 0, buff.length)))
/* 74:   */       {
/* 75:   */         //int bytesRead;
/* 76:79 */         bos.write(buff, 0, bytesRead);
/* 77:   */       }
/* 78:83 */       bos.flush();
/* 79:   */       
/* 80:85 */       bos.close();
/* 81:   */     }
/* 82:   */     catch (Exception e)
/* 83:   */     {
/* 84:89 */       e.printStackTrace();
/* 85:   */     }
/* 86:   */   }
/* 87:   */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.app.zhcx.qycx.ZhcxQycxController
 * JD-Core Version:    0.7.0.1
 */